package com.forclass;

import java.lang.reflect.InvocationTargetException;

public class FactoryClass {
    private FactoryClass(){

    }
    public static IBook getInstance(String className) {
        try {
            Object obj = Class.forName(className).getDeclaredConstructor().newInstance();
            if (obj instanceof IBook) {
                return (IBook) obj;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
